package main

import (
	"context"
	"git.900sui.cn/kc/base/utils"
	"git.900sui.cn/kc/kcgin"
	"git.900sui.cn/kc/kcgin/logs"
	"git.900sui.cn/kc/rabbitmq"
	"git.900sui.cn/kc/rpcinterface/client/product"
	"github.com/streadway/amqp"
	"strconv"
)

//修改预警
func main() {
	rpcProduct := new(product.Product).Init()
	defer rpcProduct.Close()
	logs.Info("Environment Variable:MSF_ENV:", kcgin.KcConfig.RunMode)
	new(utils.KcLog).GetInstance(kcgin.AppConfig.String("products.log.updateWarnDetails"))
	err := rabbitmq.Rabbitmq.Consume(kcgin.AppConfig.String("products.queue.updateWarnDetails"), func(msg amqp.Delivery) {
		productId, _ := strconv.Atoi(string(msg.Body))
		reply := false
		err := rpcProduct.MqUpdateWarn(context.Background(), productId, &reply)
		if err != nil {
			utils.Logerr.Printf("修改商品预警调用错误，args:%s, err:%s", productId, err)
		}
	})

	if err != nil {
		utils.Logerr.Printf("修改商品预警错误, err: %s", err.Error())
	}
}
